package com.triones.biz.infra.service.ocr.utils;

import com.triones.biz.infra.service.ocr.BaiduOcrAuthServe;

import java.net.URLEncoder;

/**
 * 图片文字识别工具
 *
 * @Author: triones
 */
public class AccurateBasic {

    public static String accurateBasic(byte[] imgData) {
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic";
        try {
            String imgStr = Base64Util.encode(imgData);
            String imgParam = URLEncoder.encode(imgStr, "UTF-8");
            String param = "image=" + imgParam;
            String result = HttpUtil.post(url, BaiduOcrAuthServe.getAuth(), param);
//            String result = HttpUtil.post(url, "24.fa42cd05ca7204f11c811df3d1b72980.2592000.1702449529.282335-42918467", param);
            System.out.println("识别的信息" + result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
